package com.tomatozq.dao;

import static com.tomatozq.dao.SysLogDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.tomatozq.model.SysLog;
import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface SysLogMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<SysLog> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("SysLogResult")
    SysLog selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SysLogResult", value = {
        @Result(column="id_", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="operation_", property="operation", jdbcType=JdbcType.VARCHAR),
        @Result(column="record_time", property="recordTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="content_type", property="contentType", jdbcType=JdbcType.VARCHAR),
        @Result(column="proc_inst_id_", property="procInstId", jdbcType=JdbcType.VARCHAR),
        @Result(column="source_", property="source", jdbcType=JdbcType.VARCHAR),
        @Result(column="content_", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<SysLog> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(sysLog);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, sysLog);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, sysLog)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(SysLog record) {
        return insert(SqlBuilder.insert(record)
                .into(sysLog)
                .map(id).toProperty("id")
                .map(operation).toProperty("operation")
                .map(recordTime).toProperty("recordTime")
                .map(userName).toProperty("userName")
                .map(contentType).toProperty("contentType")
                .map(procInstId).toProperty("procInstId")
                .map(source).toProperty("source")
                .map(content).toProperty("content")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(SysLog record) {
        return insert(SqlBuilder.insert(record)
                .into(sysLog)
                .map(id).toPropertyWhenPresent("id", record::getId)
                .map(operation).toPropertyWhenPresent("operation", record::getOperation)
                .map(recordTime).toPropertyWhenPresent("recordTime", record::getRecordTime)
                .map(userName).toPropertyWhenPresent("userName", record::getUserName)
                .map(contentType).toPropertyWhenPresent("contentType", record::getContentType)
                .map(procInstId).toPropertyWhenPresent("procInstId", record::getProcInstId)
                .map(source).toPropertyWhenPresent("source", record::getSource)
                .map(content).toPropertyWhenPresent("content", record::getContent)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SysLog>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, operation, recordTime, userName, contentType, procInstId, source, content)
                .from(sysLog);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SysLog>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, operation, recordTime, userName, contentType, procInstId, source, content)
                .from(sysLog);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default SysLog selectByPrimaryKey(String id_) {
        return SelectDSL.selectWithMapper(this::selectOne, id, operation, recordTime, userName, contentType, procInstId, source, content)
                .from(sysLog)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(SysLog record) {
        return UpdateDSL.updateWithMapper(this::update, sysLog)
                .set(id).equalTo(record::getId)
                .set(operation).equalTo(record::getOperation)
                .set(recordTime).equalTo(record::getRecordTime)
                .set(userName).equalTo(record::getUserName)
                .set(contentType).equalTo(record::getContentType)
                .set(procInstId).equalTo(record::getProcInstId)
                .set(source).equalTo(record::getSource)
                .set(content).equalTo(record::getContent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(SysLog record) {
        return UpdateDSL.updateWithMapper(this::update, sysLog)
                .set(id).equalToWhenPresent(record::getId)
                .set(operation).equalToWhenPresent(record::getOperation)
                .set(recordTime).equalToWhenPresent(record::getRecordTime)
                .set(userName).equalToWhenPresent(record::getUserName)
                .set(contentType).equalToWhenPresent(record::getContentType)
                .set(procInstId).equalToWhenPresent(record::getProcInstId)
                .set(source).equalToWhenPresent(record::getSource)
                .set(content).equalToWhenPresent(record::getContent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(SysLog record) {
        return UpdateDSL.updateWithMapper(this::update, sysLog)
                .set(operation).equalTo(record::getOperation)
                .set(recordTime).equalTo(record::getRecordTime)
                .set(userName).equalTo(record::getUserName)
                .set(contentType).equalTo(record::getContentType)
                .set(procInstId).equalTo(record::getProcInstId)
                .set(source).equalTo(record::getSource)
                .set(content).equalTo(record::getContent)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(SysLog record) {
        return UpdateDSL.updateWithMapper(this::update, sysLog)
                .set(operation).equalToWhenPresent(record::getOperation)
                .set(recordTime).equalToWhenPresent(record::getRecordTime)
                .set(userName).equalToWhenPresent(record::getUserName)
                .set(contentType).equalToWhenPresent(record::getContentType)
                .set(procInstId).equalToWhenPresent(record::getProcInstId)
                .set(source).equalToWhenPresent(record::getSource)
                .set(content).equalToWhenPresent(record::getContent)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}